<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>trim方法</title>
</head>

<body>
    <script type="text/javascript">
        /* 
        trim方法用来删除字符串前后的空格 
         */
        var str = "     hello world     ";
        console.log('(' + str.trim() + ')');//(hello world) 
        console.log('(' + str + ')');//(     hello world     ) 
    </script>

</body>

</html>